<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div>
      <h1>ES2015模板字符串</h1>
    </div>
    <script>
      //以前的方法
      const str = "hello es2015, this is a string";
      //模板字符串
      const str1 = `hello es2015, this is a \`string\` `;
      console.log(str1); //hello es2015, this is a `string`

      //换行
      const str2 = `hello es2015,  
       this is a string`;
      console.log(str2);
      //   hello es2015,
      //    this is a string

      //插值，嵌入
      const name = "xjq";
      const msg = `hhh,${name}--- ${1 * 5}---${Math.floor(4.51)}`;
      console.log(msg); //hhh,xjq--- 5---4
    </script>
  </body>
</html>
